package club.baimahu.pencil.domain.entity.order;

import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

@Data
public class CommodityList {

    private List<Commodity> commodityList;

    public CommodityList(){}
    public CommodityList(List<Commodity> commodityList){
        this.commodityList = commodityList;
    }

    public double totalAmount(){
        double total = 0 ;
        for(Commodity commodity:commodityList){
            total += commodity.getAmount();
        }
        return total;
    }

    public BigDecimal totalMoney(){
        BigDecimal total = BigDecimal.ZERO ;
        for(Commodity commodity:commodityList){
            total = total.add(commodity.getGoods().getSellPrice().multiply(new BigDecimal(commodity.getAmount())));
        }
        return total;
    }
}
